// pages/TradingAreaCenter/components/shopItem/shopitem.js
const controller = require("../../../controllers/Controller").controller

Component({
  options: {
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array,
      default () {
        return []
      }
    },
    openModify: {
      type: Boolean,
      default: false
    },
    openDelete: {
      type: Boolean,
      default: false
    },
    openPutSale: {
      type: Boolean,
      default: false
    },
    openExamine: {
      type: Boolean,
      default: false
    },
    isNoDetail: {
      type: Boolean,
      default: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    listPage: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //删除礼一卡通
    delBags(e) {
      let id = e.currentTarget.dataset.id
      controller.delBags({
        couponBagId: id
      }).then(res => {
        wx.showToast({
          icon: "none",
          title: '删除成功',
          duration: 1500
        })
      })
    },

    //跳转券礼包详情
    toBagDetail(e) {
      let id = e.currentTarget.dataset.id
      let type = e.currentTarget.dataset.type
      let isNoDetail = this.data.isNoDetail
      if (isNoDetail) return

      wx.navigateTo({
        url: '/pages/TradingAreaCenter/addCouponBag?sort=1&id=' + id + "&type=" + type,
      })
    },
    // 重新提交审核
    reAddBag(e) {
      let id = e.currentTarget.dataset.id
      let type = e.currentTarget.dataset.type
      wx.navigateTo({
        url: '/pages/TradingAreaCenter/addCouponBag?id=' + id + "&type=" + type,
      })
    },
    //冻结解冻优惠券
    closeCoupon(e) {
      let state = e.currentTarget.dataset.state
      let id = e.currentTarget.dataset.id
      this.triggerEvent('closeCoupon', {
        state,
        id
      })
    },
    //冻结解冻优惠券
    examine(e) {
      let id = e.currentTarget.dataset.id
      this.triggerEvent('examine', {
        id
      })
    },
    toUserDetail(e) {
      let id = e.currentTarget.dataset.id
      let type = e.currentTarget.dataset.type
      wx.navigateTo({
        url: '/pages/TradingAreaCenter/userDetail?id=' + id + "&type=" + type,
      })
    },
    //查看理由
    seeReason(e) {
      let index = e.currentTarget.dataset.index
      let reason = this.data.list[index].failDesc || '123'
      wx.showModal({
        title: "原因",
        showCancel: false,
        content: reason
      })
    },



  }


})